#include <stdio.h>

#define MAX_SIZE 51

inline int maxn(int a, int b, int c, int d)
{
	int t = a;
	t = (t<b ? b : t);
	t = (t<c ? c : t);
	t = (t<d ? d : t);
	return t;
}

int main(int argc, char *argv[])
{
	int a[MAX_SIZE][MAX_SIZE], f[101][51][51];
	int m, n, i, j, k, x1, x2;

	scanf("%d %d", &m, &n);

	for (i=1; i<=m; i++) {
		for (j=1; j<=n; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (k=2; k<=m+n-1; i++) {
		for (x1=1; x1<=k; x1++) {
			if (x1<=k) {
				for (x2=1; x2<=k; x2++) {
					if (x2<=k) {
						f[k][x1][x2] = maxn(f[k-1][x1-1][x2], f[k-1][x1-1][x2-1], f[k-1][x1][x2-1], f[k-1][x1][x2]);
						f[k][x1][x2] += (x1==x2?a[x1][k-x1+1]: (a[x1][k-x1+1]+a[x2][k-x2+1]));
					}
				}
			}
		}
	}

	printf("%d\n", f[m+n-1][m][m]);

	return 0;
}
